package com.yu.crm.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yu.crm.domain.pojo.WfAppInfo;
import com.yu.crm.mapper.WfAppInfoMapper;
import com.yu.crm.service.WfAppInfoService;
import com.yxzz.common.config.UserCacheManager;
import com.yxzz.common.helper.DateHelpers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 工作流程表 服务实现类
 * </p>
 *
 * @author donnie-bin
 * @since 2019-10-08
 */
@Service
public class WfAppInfoServiceImpl extends ServiceImpl<WfAppInfoMapper, WfAppInfo> implements WfAppInfoService {

    @Autowired
    UserCacheManager userCacheManager;

    /**
     * 新增
     * @param req
     */
    @Override
    public void add(WfAppInfo req) {
        String userId = userCacheManager.getCurrentUser().getUserId();
        req.setCreateUserId(userId);
        req.setIsDeleted(0);
        req.setGmtCreate(DateHelpers.now());
        req.setGmtModified(DateHelpers.now());
        this.saveOrUpdate(req);
    }

    /**
     * 查询
     * @param appId
     */
    @Override
    public WfAppInfo detail(String appId) {
        return baseMapper.selectAppInfoById(appId);
    }

    /**
     * 列表
     * @return
     */
    @Override
    public List<WfAppInfo> getList() {
        return this.list();
    }

}
